import wpath
from scripts.deploy.accounts import *

token = Token.at("0x1D35De51507Dc5017Dc902C429388D9a9c049218")


def deploy():
    # 指定nonce,可以保证合约地址一样
    controller = gov.deploy(Controller, rewards, nonce=0)


def config():
    def controller_setParams(accounts, gov, rewards, getter, setter, val):
        if not val:
            # 如果变量没有值，则表示采用默认的备用账户地址accounts[1]
            val = accounts[1]

        # 加载已经部署的合约
        # controller = Controller.at("0xf34169b02747E45DA4AB7844d38D95f05060b60d")

        # getattr(controller, setter)(val, {"from": accounts[1]})
        getattr(controller, setter)(val, {"from": gov})

        assert getattr(controller, getter)() == val

        if getter == "governance":
            getattr(controller, setter)(val, {"from": gov})

    # Controller合约中，setSplit，setOneSplit，setGovernance三个操作都要求使用管理者账户操作
    params = [
        ("split", "setSplit", 1000),
        ("onesplit", "setOneSplit", None),
        ("governance", "setGovernance", None),
    ]

    for getter, setter, val in params:
        controller_setParams(accounts, gov, rewards, getter, setter, val)
